package com.qire.manhua.dialog;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.qire.common.basic.ObjectUtil;
import com.qire.common.support.base.BaseDialog;
import com.qire.manhua.R;
import com.qire.manhua.databinding.DialogPayWaySelectorOfBuyCoinBinding;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

/**
 * 支付方式选择器弹窗：在金币市场购买时弹出
 */
public class PayWaySelectorOfBuyCoinDialog extends BaseDialog {

    private final DialogPayWaySelectorOfBuyCoinBinding binding;
    private final View.OnClickListener paymentMethodListener;

    private final ObservableField<CharSequence> waresFee        = new ObservableField<>();
    private final ObservableField<CharSequence> waresDescribe   = new ObservableField<>();

    public PayWaySelectorOfBuyCoinDialog(@NonNull Context context, View.OnClickListener paymentMethodListener) {
        super(context, R.style.FullDialog);
        this.paymentMethodListener = paymentMethodListener;

        LayoutInflater inflater = LayoutInflater.from(context);
        binding = DialogPayWaySelectorOfBuyCoinBinding.inflate(inflater);
        binding.setPayWaySelectorOfBuyCoinDialog(this);
        this.setContentView(binding.getRoot());
    }

    public PayWaySelectorOfBuyCoinDialog setWaresFee(CharSequence waresFee){
        this.waresFee.set(waresFee);
        return this;
    }
    public PayWaySelectorOfBuyCoinDialog setWaresDescribe(CharSequence waresDescribe){
        this.waresDescribe.set(waresDescribe);
        return this;
    }

    public ObservableField<CharSequence> getWaresFee() {
        return waresFee;
    }

    public ObservableField<CharSequence> getWaresDescribe() {
        return waresDescribe;
    }

    public void paymentMethodOnClick(View view){
        if(ObjectUtil.nonNull(paymentMethodListener)) {
            paymentMethodListener.onClick(view);
        }
        dismiss();
    }

}
